import { useSearchParams } from 'react-router-dom'
import React, { useEffect, useState } from "react";
// import { } from './style'
import CitySelect from './CitySelect'
import Banners from "./Banners";
import SetMeal from "./SetMeal";
import StoreList from "./StoreList";
import StoreInfo from './StoreInfo';
import { getBanners } from '@/api/request'
import { getRestaurants } from '@/api/request'


const Home = () => {
    const [restaurants, setRestaurants] = useState([])
    const [search] = useSearchParams()
    const cityName = search.get('name') || '';
    // console.log(cityName);
    const [banners, setBanners] = useState([])
    // console.log(banners);

    useEffect(() => {
        (async () => {
            let { data: bannerData } = await getBanners();
            let { data: resData } = await getRestaurants();
            setBanners(bannerData)
            // console.log(resData);
            setRestaurants(resData)
        })()
    }, [])

    return (

        <div>
            <CitySelect cityName={cityName} />
            {/* Banners 横幅广告业务 */}
            <Banners banners={banners} />
            {/* SetMeal 业务 切页面 */}
            <SetMeal />
            <StoreList />
            <StoreInfo restaurants={restaurants} />
        </div>
    )
}

export default Home

// rmc / rsc 快速生成